home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / dbase / vpi1_330.zip / FILTERCR.PRG < prev    next >
Text File  |  1991-12-30  |  3KB  |  82 lines

  1. **************************************************************************
  2. **  FILTERCR.PRG
  3. **  (C) Copyright 1990-92, Sub Rosa Publishing Inc.
  4. **
  5. **  A demonstration program provided to VP-Info users.
  6. **  This program may be copied freely. If it is used in commercial code,
  7. **  please credit the source, Sub Rosa Publishing Inc.
  8. **
  9. **  FILTERCR demonstrates the use of sequential file functions to produce
  10. **  an altered copy of given file.
  11. **
  12. **  FILTERCR is compatible with all current versions of VP-Info.
  13. **                                                   
  14. **  FILTERCR provides a facility not usually available on text editors.
  15. **  It replaces a selected character in a file with a carriage return and
  16. **  a line feed. One use of this program is to replace a long list
  17. **  of comma-separated items (as in a 'C' program) with a list presenting
  18. **  one item per line.
  19. **
  20. **  Bernie Melman and Sid Bursten
  21. ***************************************************************************
  22. SET raw on ; no extra space between print fields
  23. * initialize variables
  24. infile=blank(12)
  25. outfile=blank(12)
  26. key_char=' '
  27. inp_char=' '
  28. WINDOW ; get rid on any window left open.
  29. ERASE ; clear screen
  30. * set up input screen - note that all variables used have been initialized
  31. * .. lines are picture clauses forcing upper case for infile and outfile
  32. TEXT
  33. .. infile  !!!!!!!!!!!!
  34. .. outfile !!!!!!!!!!!!
  35.  
  36.                          INPUT FILE: @infile      (try FILTER.IN)  
  37.  
  38.                         OUTPUT FILE: @outfile     (try FILTER.OUT)
  39.  
  40. Substitute CR/LF for this character: @key_char
  41. ENDTEXT
  42. READ                                                  
  43. *; get rid of old output
  44. DELETE file &outfile ; note if file name has no extension, include '.' in name
  45. ?
  46. IF ropen(infile); don't even try if files won't open!
  47.    IF wopen(outfile,2)
  48.       ? ;start new line
  49.       DO WHILE in(inp_char); start of main loop
  50.          ?? inp_char;  echo characters to screen
  51.          IF inp_char <> key_char
  52.             ok= OUT(inp_char,2)
  53.          ELSE
  54.             ok= out(chr(13),2)
  55.             ok= out(chr(10),2)
  56.          ENDIF 
  57.       ENDDO ; end of main loop
  58. * close files
  59.       IF .not. close(1)
  60.          ? "Problem closing file :"+infile
  61.       ENDIF
  62.       IF .not. close(2)
  63.          ? "Problem closing output file :"+outfile
  64.       ENDIF
  65. * done
  66.    ELSE
  67.       ? "Unable to open output file :"+outfile
  68.       CANCEL
  69.    ENDIF
  70. ELSE
  71.    ? "Unable to open input file :"+infile
  72.    CANCEL
  73. ENDIF
  74. ? 'Press a key to see the output' 
  75. dummy=inkey() ; used instead of WAIT command to control prompt
  76. erase
  77. TEXT &outfile
  78. WAIT
  79. CHAIN samples
  80. *
  81. *                           *** end of FILTERCR.PRG ***
  82.